package com.liang.service.bill;

import com.liang.dao.BaseDao;
import com.liang.dao.bill.BillDaoImpl;
import com.liang.pojo.Bill;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

public class BillServiceImpl implements BillService{
    BillDaoImpl billDao = null;
    public BillServiceImpl() {
        billDao = new BillDaoImpl();
    }

    @Override
    public int getCount(String productName, Integer providerId, Integer isPayment) {
        int count = 0;
        Connection connection = BaseDao.getConnection();
        count = billDao.getCount(connection, productName, providerId, isPayment);
        return count;
    }

    @Override
    public List<Bill> getBillList(String productName, Integer providerId, Integer isPayment,int pageNo,int pageSize) {
        List<Bill> list = new ArrayList<>();
        Connection connection = BaseDao.getConnection();
        list = billDao.getBillList(connection,productName,providerId,isPayment,pageNo,pageSize);

        return list;
    }

    @Override
    public Bill getBillListSearch(String params,Integer id) {
        Bill bill = null;
        Connection connection = BaseDao.getConnection();
        bill = billDao.getBillListSearch(connection, params,id);
        return bill;
    }

    @Override
    public Boolean addBill(Bill bill) {
        Boolean flag = false;
        Connection connection = BaseDao.getConnection();
        flag = billDao.addBill(connection, bill);

        return flag;
    }

    @Override
    public Boolean updateBill(Bill bill) {
        Boolean flag = false;
        Connection connection = BaseDao.getConnection();
        flag = billDao.updateBill(connection, bill);

        return flag;
    }

    @Override
    public Boolean deleteBill(Integer id) {
        Boolean flag = false;
        Connection connection = BaseDao.getConnection();
        flag = billDao.deleteBill(connection, id);

        return flag;
    }
}
